package com.jing.weibo.service.system;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.jing.system.model.PageCls;
import com.jing.weibo.mapper.system.FeedbackMapper;
import com.jing.weibo.pojo.system.Feedback;

/**
 * 反馈建议的Service
 * @author jing.yue
 * @version 2012/09/24 1.0.0
 */
@Component
public class FeedbackService {

	@Autowired
	private FeedbackMapper feedbackMapper;

	/**
	 * 保存反馈建议
	 * @param feedback
	 * @throws Exception
	 */
	public void saveFeedback(Feedback feedback) throws Exception {
		feedbackMapper.saveFeedback(feedback);
	}

	/**
	 * 分页获取反馈列表
	 * @param feedback
	 * @return
	 * @throws Exception
	 */
	public Map<String, Object> findFeedback(Feedback feedback) throws Exception {
		List<Feedback> feedbacks = feedbackMapper.findFeedback(feedback);
		Integer countSize = feedbackMapper.findFeedbackCount(feedback);
		PageCls pageCls = PageCls.setPageCls(feedback.getPage(), feedback.getSize(), null, null, countSize, feedbacks.size(), feedbacks);
		return pageCls.getPageInfo();
	}

	/**
	 * 根据编号和审核状态修改反馈信息
	 * @param feedback
	 * @throws Exception
	 */
	public void updateCheckFeedback(Feedback feedback) throws Exception {
		feedbackMapper.updateCheckFeedback(feedback);
	}

	/**
	 * 根据ID获取反馈对象
	 * @param id
	 * @return
	 * @throws Exception
	 */
	public Feedback findByIdFeedback(Integer id) throws Exception {
		return feedbackMapper.findByIdFeedback(id);
	}
}
